package com.yanqu.road.server.cmd.activity.liondance;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LionDanceProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.liondance.CrossLionDanceActivityMgr;
import com.yanqu.road.server.manager.activity.liondance.LionDanceActivity;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = Protocol.C_LION_DANCE_CHECK_APPLY_STATE, desc = "检查申请状态")
public class CrossLionDanceCheckApplyStatusCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LionDanceProto.CrossLionDanceCheckApplyStatusReqMsg msg = LionDanceProto.CrossLionDanceCheckApplyStatusReqMsg.parseFrom(packet.getBytes());
        LionDanceActivity activity = CrossLionDanceActivityMgr.getLionDanceActivity(msg.getActivityId());
        if(activity != null){
            activity.checkApplyState(serverId, packet.getPlayerId(), msg.getReq());
        }else {
            MessageHelper.sendPacket(serverId, packet.getPlayerId(), YanQuMessageUtils.buildMessage(Protocol.U_LION_DANCE_CHECK_APPLY_STATE,
                    LionDanceProto.LionDanceCheckApplyStatusRespMsg.newBuilder().setRet(GameErrorCode.E_ACTIVITY_OVER_TIME)));
        }
    }

    @Override
    public void sendData() {

    }
}
